<template>
    <view class="content">		
		<view class="uni-form-item uni-column">
			<view class="title">服务器路径：</view>
			<multi-input type="text" focus clearable v-model="path" placeholder="请输入路径"></multi-input>
		</view>
        <view class="btn-row">
            <button type="primary" class="primary" @tap="changePath" :loading="loading">修 改</button>
        </view>
        <view>
            <rich-text :nodes="strings"></rich-text>
        </view>
    </view>
</template>

<script>
	import store from '@/vuex'
	import multiInput from '../../components/multiInput.vue'
	
	export default {
		components: {
			multiInput
		},
		data() {
			return {
				path: '',
				strings:''
			}
		},
		computed:{
			loading:{
				get () {
				  return store.getters.getLoadingStatus
				},
				set (value) {
				  store.commit('updateLoadingStatus', value)
				} 
			},
			onMockjs:{
				get () {
				  return store.getters.getOnMockjs
				},
				set (value) {
				  store.commit('updateOnMockjs', value)
				} 
			},
			data:{
				get () {
				  return store.getters.getData
				},
				set (value) {
				  store.commit('updateData', value)
				} 
			}
		},
		methods: {
			changePath(){
				this.loading = true
				uni.setStorageSync('default_path',this.path)
				this.loading = false
				if(this.path == '') this.onMockjs = true
				else this.onMockjs = false
				// #ifdef APP-PLUS
				plus.runtime.restart();
				// #endif
				// #ifdef H5
				window.location.href = '/#/'
				// #endif
				/* uni.reLaunch({
					url: '../index/index?path=' + this.path
				}); */
			}
		},
        onReady() {
			this.strings = JSON.stringify(this.data)
			this.path = uni.getStorageSync('default_path')
        }
	}
</script>

<style>
	.content {
		padding: 20upx;
	}
	.btn-row {
		margin-top: 50upx;
	}
	button.primary {
		background-color: #0faeff;
	}
</style>
